//
//  KKDocumentsTableViewController.m
//  KKDocuments
//
//  Created by Mac mini on 16/2/2.
//  Copyright © 2016年 JuniorCodingPerson. All rights reserved.
//

#import "KKDocumentsTableViewController.h"

#import "KKPreviewController.h"

@interface KKDocumentsTableViewController () {
    
    NSArray *_kk_fileNames;
}

@end

@implementation KKDocumentsTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    _kk_fileNames = @[@"test1.xls",@"test2.xlsx",@"test3.doc",@"test4.docx",@"test5.pdf"];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return _kk_fileNames.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"kkDocumentsCellIdentifier" forIndexPath:indexPath];
    
    cell.textLabel.text = _kk_fileNames[indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    KKPreviewController *previewController = [[KKPreviewController alloc] init];
    previewController.currentPreviewItemIndex = 1;
    previewController.kk_fileName = _kk_fileNames[indexPath.row];
    [self.navigationController pushViewController:previewController animated:YES];
}

@end
